'use strict';
const ObjectId = require('mongodb').ObjectId;

module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;

  const userSchema = new Schema({
    name: String,
    mail: String,
    password: String,
    phone: String,
    avatar: String,
    i_liked: Array,
    liked_me: Array,
    my_followed: Array,
    followed_me: Array,
    favorited: [{ type: ObjectId }],
    // messages: Array,
    messages: [
      {
        articleId: ObjectId,
        messageType: String,
        time: String,
        fromUser: ObjectId,
        content: String,
      },
    ],
  });

  return mongoose.model('user', userSchema, 'user');
};
